package com.population.service.impl;

import com.populatton.base.RespEnum;
import com.populatton.common.RevertException;
import com.mis.dao.PersonalInfoMapper;
import com.mis.dao.UserMapper;
import com.mis.entity.Account;
import com.mis.entity.model.res.ResLoginVO;
import com.population.LoginService;
import com.populatton.utils.ParametersUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Title
 * @Author shmily
 * @Date 2019/9/26
 */

@Slf4j
@Service
public class LoginServiceImpl implements LoginService {

    @Autowired
    private PersonalInfoMapper personalInfoMapper;

    @Autowired
    private UserMapper userMapper;

    @Override
    public ResLoginVO login(String username, String password) {
        log.info("用户登录 ,username:"+username);
        Account user = userMapper.selectById(username);
        if(ParametersUtil.isNull(user)){
            throw new RevertException(RespEnum.NO_THIS_USER);
        }
        if (!password.equals(user.getPassword())){
            throw new RevertException(RespEnum.USERNAME_PASSWORD_ERROR);
        }

        return null;
    }



    private ResLoginVO userDetail(){

    }
}
